// 价格大数据
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
import type { GetGoodsCategoryResponseList } from "/#/viewTypes/sourcingBigData";
enum Api {
  getRemarkId = '/jsk/change/remark',
  GetUrlByDetails = '/jsk/plugin/company-info', // 获取工程寻找源插件地址（二级页面）
  GetUrl = '/jsk/plugin/combined-search', // 工程寻源（一级页面）
  GetAreaTree = '/goods/area/tree',
  GetGoodsAvgPriceList = '/goods/spjqjjfy',
  GetGoodsPriceDetail = '/goods/spjgxq',
  GetGoodsHistoryPriceDetail = '/goods/price-trend',
  GetGoodsFuturePriceMonthDetail = '/goods/future/trend/month/list',
  GetGoodsFuturePriceWeekDetail = '/goods/future/trend/week/list',
  GetSuppliers = '/goods/suppliers',
}

export function getCompanyId(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.getRemarkId, params },
    {
      errorMessageMode: mode,
    },
  );
}

export function getCompanyInfoUrl(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetUrlByDetails, params },
    {
      errorMessageMode: mode,
    },
  );
}

export function getProjectUrl(mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetUrl },
    {
      errorMessageMode: mode,
    },
  );
}

export function getAreaTree(mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetAreaTree },
    {
      errorMessageMode: mode,
    },
  );
}

export function getGoodsAvgPriceList(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetGoodsAvgPriceList, data },
    {
      errorMessageMode: mode,
    },
  );
}

export function getGoodsPriceDetail(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetGoodsPriceDetail, data },
    {
      errorMessageMode: mode,
    },
  );
}

export function getGoodsFuturePriceMonthDetail(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetGoodsFuturePriceMonthDetail, data },
    {
      errorMessageMode: mode,
    },
  );
}

export function getGoodsFuturePriceWeekDetail(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetGoodsFuturePriceWeekDetail, data },
    {
      errorMessageMode: mode,
    },
  );
}

export function getGoodsHistoryPriceDetail(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetGoodsHistoryPriceDetail, data },
    {
      errorMessageMode: mode,
    },
  );
}

export function getSuppliers(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetSuppliers, params },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 获取商品价格寻源 商品分类
 * @param goodsType
 * @param id
 * @returns
 */
export const getGoodsCategoryApi = (goodsTypePath: string) => defHttp.request<GetGoodsCategoryResponseList>({
  method: "get",
  url: `/goods/categories${goodsTypePath}`,
  params: {},
});

/**
 * 获取商品价格寻源 常用商品分类小项
 * @returns
 */
export const getGoodsCategoryCyspApi = (typeName: string) => defHttp.request<Array<GetGoodsCategoryResponseList>>({
  method: "post",
  url: `/goods/categories/frequently/typeName`,
  data: {
    typeName
  },
});

/**
 * 价格寻源 根据商品查询列表
 * @param data
 * @returns
 */
export const getGoodsListByCategoryApi = (data: any) => defHttp.request({
  method: "post",
  url: "/goods/spjqjjfy",
  data
});
